package Wires.diagram.providers;

import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Set;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.ENamedElement;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;

/**
 * @generated
 */
public class WiresElementTypes extends ElementInitializers {

	/**
	 * @generated
	 */
	private WiresElementTypes() {
	}

	/**
	 * @generated
	 */
	private static Map elements;

	/**
	 * @generated
	 */
	private static ImageRegistry imageRegistry;

	/**
	 * @generated
	 */
	private static Set KNOWN_ELEMENT_TYPES;

	/**
	 * @generated
	 */
	public static final IElementType WiresSpecification_79 = getElementType("Wires.diagram.WiresSpecification_79"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType AtomicModelTransformation_1001 = getElementType("Wires.diagram.AtomicModelTransformation_1001"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType IdentityTransformation_1002 = getElementType("Wires.diagram.IdentityTransformation_1002"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType GenericTransformation_1003 = getElementType("Wires.diagram.GenericTransformation_1003"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType CompositeTransformation_1004 = getElementType("Wires.diagram.CompositeTransformation_1004"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType Model2TextTransformation_1005 = getElementType("Wires.diagram.Model2TextTransformation_1005"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType Query_1006 = getElementType("Wires.diagram.Query_1006"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType BasicData_1007 = getElementType("Wires.diagram.BasicData_1007"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType Model_1008 = getElementType("Wires.diagram.Model_1008"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType ModelType_1009 = getElementType("Wires.diagram.ModelType_1009"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType DecisionNode_1010 = getElementType("Wires.diagram.DecisionNode_1010"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType Library_1011 = getElementType("Wires.diagram.Library_1011"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType AtomicModelTransfomationType_1012 = getElementType("Wires.diagram.AtomicModelTransfomationType_1012"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType Model2TextTransformationType_1013 = getElementType("Wires.diagram.Model2TextTransformationType_1013"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType QueryType_1014 = getElementType("Wires.diagram.QueryType_1014"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType CompositeTransformationType_1015 = getElementType("Wires.diagram.CompositeTransformationType_1015"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType InputActualParameter_2001 = getElementType("Wires.diagram.InputActualParameter_2001"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType OutputActualParameter_2002 = getElementType("Wires.diagram.OutputActualParameter_2002"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType TypeParameter_2003 = getElementType("Wires.diagram.TypeParameter_2003"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType InputActualParameter_2004 = getElementType("Wires.diagram.InputActualParameter_2004"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType LibraryRef_2005 = getElementType("Wires.diagram.LibraryRef_2005"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType InputFormalParameter_2006 = getElementType("Wires.diagram.InputFormalParameter_2006"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType OutputFormalParameter_2007 = getElementType("Wires.diagram.OutputFormalParameter_2007"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType LibraryRef_2008 = getElementType("Wires.diagram.LibraryRef_2008"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType Model_2009 = getElementType("Wires.diagram.Model_2009"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType BasicData_2010 = getElementType("Wires.diagram.BasicData_2010"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType CompositeTransformation_2011 = getElementType("Wires.diagram.CompositeTransformation_2011"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType AtomicModelTransformation_2012 = getElementType("Wires.diagram.AtomicModelTransformation_2012"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType GenericTransformation_2013 = getElementType("Wires.diagram.GenericTransformation_2013"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType IdentityTransformation_2014 = getElementType("Wires.diagram.IdentityTransformation_2014"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType Query_2015 = getElementType("Wires.diagram.Query_2015"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType DecisionNode_2016 = getElementType("Wires.diagram.DecisionNode_2016"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType Model2TextTransformation_2017 = getElementType("Wires.diagram.Model2TextTransformation_2017"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType DataFlow_3001 = getElementType("Wires.diagram.DataFlow_3001"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType DecisionNodeTrueBranch_3002 = getElementType("Wires.diagram.DecisionNodeTrueBranch_3002"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType DecisionNodeFalseBranch_3003 = getElementType("Wires.diagram.DecisionNodeFalseBranch_3003"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	private static ImageRegistry getImageRegistry() {
		if (imageRegistry == null) {
			imageRegistry = new ImageRegistry();
		}
		return imageRegistry;
	}

	/**
	 * @generated
	 */
	private static String getImageRegistryKey(ENamedElement element) {
		return element.getName();
	}

	/**
	 * @generated
	 */
	private static ImageDescriptor getProvidedImageDescriptor(
			ENamedElement element) {
		if (element instanceof EStructuralFeature) {
			EStructuralFeature feature = ((EStructuralFeature) element);
			EClass eContainingClass = feature.getEContainingClass();
			EClassifier eType = feature.getEType();
			if (eContainingClass != null && !eContainingClass.isAbstract()) {
				element = eContainingClass;
			} else if (eType instanceof EClass
					&& !((EClass) eType).isAbstract()) {
				element = eType;
			}
		}
		if (element instanceof EClass) {
			EClass eClass = (EClass) element;
			if (!eClass.isAbstract()) {
				return Wires.diagram.part.WiresDiagramEditorPlugin
						.getInstance().getItemImageDescriptor(
								eClass.getEPackage().getEFactoryInstance()
										.create(eClass));
			}
		}
		// TODO : support structural features
		return null;
	}

	/**
	 * @generated
	 */
	public static ImageDescriptor getImageDescriptor(ENamedElement element) {
		String key = getImageRegistryKey(element);
		ImageDescriptor imageDescriptor = getImageRegistry().getDescriptor(key);
		if (imageDescriptor == null) {
			imageDescriptor = getProvidedImageDescriptor(element);
			if (imageDescriptor == null) {
				imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
			}
			getImageRegistry().put(key, imageDescriptor);
		}
		return imageDescriptor;
	}

	/**
	 * @generated
	 */
	public static Image getImage(ENamedElement element) {
		String key = getImageRegistryKey(element);
		Image image = getImageRegistry().get(key);
		if (image == null) {
			ImageDescriptor imageDescriptor = getProvidedImageDescriptor(element);
			if (imageDescriptor == null) {
				imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
			}
			getImageRegistry().put(key, imageDescriptor);
			image = getImageRegistry().get(key);
		}
		return image;
	}

	/**
	 * @generated
	 */
	public static ImageDescriptor getImageDescriptor(IAdaptable hint) {
		ENamedElement element = getElement(hint);
		if (element == null) {
			return null;
		}
		return getImageDescriptor(element);
	}

	/**
	 * @generated
	 */
	public static Image getImage(IAdaptable hint) {
		ENamedElement element = getElement(hint);
		if (element == null) {
			return null;
		}
		return getImage(element);
	}

	/**
	 * Returns 'type' of the ecore object associated with the hint.
	 * 
	 * @generated
	 */
	public static ENamedElement getElement(IAdaptable hint) {
		Object type = hint.getAdapter(IElementType.class);
		if (elements == null) {
			elements = new IdentityHashMap();

			elements.put(WiresSpecification_79, Wires.WiresPackage.eINSTANCE
					.getWiresSpecification());

			elements
					.put(AtomicModelTransformation_1001,
							Wires.WiresPackage.eINSTANCE
									.getAtomicModelTransformation());

			elements.put(IdentityTransformation_1002,
					Wires.WiresPackage.eINSTANCE.getIdentityTransformation());

			elements.put(GenericTransformation_1003,
					Wires.WiresPackage.eINSTANCE.getGenericTransformation());

			elements.put(CompositeTransformation_1004,
					Wires.WiresPackage.eINSTANCE.getCompositeTransformation());

			elements.put(Model2TextTransformation_1005,
					Wires.WiresPackage.eINSTANCE.getModel2TextTransformation());

			elements.put(Query_1006, Wires.WiresPackage.eINSTANCE.getQuery());

			elements.put(BasicData_1007, Wires.WiresPackage.eINSTANCE
					.getBasicData());

			elements.put(Model_1008, Wires.WiresPackage.eINSTANCE.getModel());

			elements.put(ModelType_1009, Wires.WiresPackage.eINSTANCE
					.getModelType());

			elements.put(DecisionNode_1010, Wires.WiresPackage.eINSTANCE
					.getDecisionNode());

			elements.put(Library_1011, Wires.WiresPackage.eINSTANCE
					.getLibrary());

			elements.put(AtomicModelTransfomationType_1012,
					Wires.WiresPackage.eINSTANCE
							.getAtomicModelTransfomationType());

			elements.put(Model2TextTransformationType_1013,
					Wires.WiresPackage.eINSTANCE
							.getModel2TextTransformationType());

			elements.put(QueryType_1014, Wires.WiresPackage.eINSTANCE
					.getQueryType());

			elements.put(CompositeTransformationType_1015,
					Wires.WiresPackage.eINSTANCE
							.getCompositeTransformationType());

			elements.put(InputActualParameter_2001,
					Wires.WiresPackage.eINSTANCE.getInputActualParameter());

			elements.put(OutputActualParameter_2002,
					Wires.WiresPackage.eINSTANCE.getOutputActualParameter());

			elements.put(TypeParameter_2003, Wires.WiresPackage.eINSTANCE
					.getTypeParameter());

			elements.put(InputActualParameter_2004,
					Wires.WiresPackage.eINSTANCE.getInputActualParameter());

			elements.put(LibraryRef_2005, Wires.WiresPackage.eINSTANCE
					.getLibraryRef());

			elements.put(InputFormalParameter_2006,
					Wires.WiresPackage.eINSTANCE.getInputFormalParameter());

			elements.put(OutputFormalParameter_2007,
					Wires.WiresPackage.eINSTANCE.getOutputFormalParameter());

			elements.put(LibraryRef_2008, Wires.WiresPackage.eINSTANCE
					.getLibraryRef());

			elements.put(Model_2009, Wires.WiresPackage.eINSTANCE.getModel());

			elements.put(BasicData_2010, Wires.WiresPackage.eINSTANCE
					.getBasicData());

			elements.put(CompositeTransformation_2011,
					Wires.WiresPackage.eINSTANCE.getCompositeTransformation());

			elements
					.put(AtomicModelTransformation_2012,
							Wires.WiresPackage.eINSTANCE
									.getAtomicModelTransformation());

			elements.put(GenericTransformation_2013,
					Wires.WiresPackage.eINSTANCE.getGenericTransformation());

			elements.put(IdentityTransformation_2014,
					Wires.WiresPackage.eINSTANCE.getIdentityTransformation());

			elements.put(Query_2015, Wires.WiresPackage.eINSTANCE.getQuery());

			elements.put(DecisionNode_2016, Wires.WiresPackage.eINSTANCE
					.getDecisionNode());

			elements.put(Model2TextTransformation_2017,
					Wires.WiresPackage.eINSTANCE.getModel2TextTransformation());

			elements.put(DataFlow_3001, Wires.WiresPackage.eINSTANCE
					.getDataFlow());

			elements.put(DecisionNodeTrueBranch_3002,
					Wires.WiresPackage.eINSTANCE.getDecisionNode_TrueBranch());

			elements.put(DecisionNodeFalseBranch_3003,
					Wires.WiresPackage.eINSTANCE.getDecisionNode_FalseBranch());
		}
		return (ENamedElement) elements.get(type);
	}

	/**
	 * @generated
	 */
	private static IElementType getElementType(String id) {
		return ElementTypeRegistry.getInstance().getType(id);
	}

	/**
	 * @generated
	 */
	public static boolean isKnownElementType(IElementType elementType) {
		if (KNOWN_ELEMENT_TYPES == null) {
			KNOWN_ELEMENT_TYPES = new HashSet();
			KNOWN_ELEMENT_TYPES.add(WiresSpecification_79);
			KNOWN_ELEMENT_TYPES.add(AtomicModelTransformation_1001);
			KNOWN_ELEMENT_TYPES.add(IdentityTransformation_1002);
			KNOWN_ELEMENT_TYPES.add(GenericTransformation_1003);
			KNOWN_ELEMENT_TYPES.add(CompositeTransformation_1004);
			KNOWN_ELEMENT_TYPES.add(Model2TextTransformation_1005);
			KNOWN_ELEMENT_TYPES.add(Query_1006);
			KNOWN_ELEMENT_TYPES.add(BasicData_1007);
			KNOWN_ELEMENT_TYPES.add(Model_1008);
			KNOWN_ELEMENT_TYPES.add(ModelType_1009);
			KNOWN_ELEMENT_TYPES.add(DecisionNode_1010);
			KNOWN_ELEMENT_TYPES.add(Library_1011);
			KNOWN_ELEMENT_TYPES.add(AtomicModelTransfomationType_1012);
			KNOWN_ELEMENT_TYPES.add(Model2TextTransformationType_1013);
			KNOWN_ELEMENT_TYPES.add(QueryType_1014);
			KNOWN_ELEMENT_TYPES.add(CompositeTransformationType_1015);
			KNOWN_ELEMENT_TYPES.add(InputActualParameter_2001);
			KNOWN_ELEMENT_TYPES.add(OutputActualParameter_2002);
			KNOWN_ELEMENT_TYPES.add(TypeParameter_2003);
			KNOWN_ELEMENT_TYPES.add(InputActualParameter_2004);
			KNOWN_ELEMENT_TYPES.add(LibraryRef_2005);
			KNOWN_ELEMENT_TYPES.add(InputFormalParameter_2006);
			KNOWN_ELEMENT_TYPES.add(OutputFormalParameter_2007);
			KNOWN_ELEMENT_TYPES.add(LibraryRef_2008);
			KNOWN_ELEMENT_TYPES.add(Model_2009);
			KNOWN_ELEMENT_TYPES.add(BasicData_2010);
			KNOWN_ELEMENT_TYPES.add(CompositeTransformation_2011);
			KNOWN_ELEMENT_TYPES.add(AtomicModelTransformation_2012);
			KNOWN_ELEMENT_TYPES.add(GenericTransformation_2013);
			KNOWN_ELEMENT_TYPES.add(IdentityTransformation_2014);
			KNOWN_ELEMENT_TYPES.add(Query_2015);
			KNOWN_ELEMENT_TYPES.add(DecisionNode_2016);
			KNOWN_ELEMENT_TYPES.add(Model2TextTransformation_2017);
			KNOWN_ELEMENT_TYPES.add(DataFlow_3001);
			KNOWN_ELEMENT_TYPES.add(DecisionNodeTrueBranch_3002);
			KNOWN_ELEMENT_TYPES.add(DecisionNodeFalseBranch_3003);
		}
		return KNOWN_ELEMENT_TYPES.contains(elementType);
	}

}
